<script>
    function loadTagAndTopNav() {
        $("#topNav_submit").addClass("active");
        token = window.localStorage.getItem('xjtu-idle-token');
        $.ajax({
            type: "get",
            url: 'get/user/justUserName',
            headers: { 'Authorization': `Bearer ${token}` },
            success(resJson) {
                if (resJson.success){
                    $('#welcome').html("当前用户: " + resJson.data.body);
                    // 改变内容和链接
                    $("#topNav_user").html(resJson.data.body);
                    $("#topNav_user").attr('href', '/myhome');
                    $("#topNav_logout").css('display', '');
                    $('[data-toggle="tooltip"]').tooltip()
                } else {
                    $('#welcome').html('<a href="/login">请登录</a>');
                }
            }
        })
    }

    function loadFileinputPlugin() {
        $("#uploadfile").fileinput({
            allowedFileTypes: ['image'],
            language: 'zh',
            theme: 'fas',
            uploadUrl: '/submit/file/itemCover',
            async: false,
            maxFileCount: 1,
            allowedFileExtensions: [],
            ajaxSettings: {
                dataType: 'json'
            },
            maxFileSize: 10 * 1024,
        })
    }
</script>